package com.teach.servlet.web2;

import java.io.IOException;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.teach.entity.News;
import com.teach.service.NewsService;
import com.teach.service.impl.NewsServiceImpl;

@WebServlet("/web2/news-del.s")
public class NewsDeleteServlet extends HttpServlet {

	private NewsService service = new NewsServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		
		String msg = "ok";
		
		try {
			String newsId = request.getParameter("newsId");
			service.delete(newsId);
		}catch (Exception e) {
			msg = e.getMessage();
		}
		

		response.reset();
		response.setContentType("text/json;charset=UTF-8");
		response.getWriter().print(JSON.toJSONString(msg));
		response.flushBuffer();
	}
}
